package com.example.project;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.widget.TextView;

public class Carta extends Activity{
	
	protected TextView menu_primeros;
	protected TextView menu_segundos;
	protected TextView menu_postres;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.menjar_carta);
		String linea = " ";
		menu_primeros = (TextView)findViewById(R.id.text_carta);
		menu_segundos = (TextView)findViewById(R.id.menu_segundos);
		menu_postres = (TextView)findViewById(R.id.menu_postres);
		
		Typeface font = Typeface.createFromAsset(getAssets(), "tiza.ttf");
		menu_primeros.setTypeface(font);
		
		try {
			InputStream fraw_primeros = getResources().openRawResource(R.raw.menu_primers);
			InputStream fraw_segundos = getResources().openRawResource(R.raw.menu_segons);
			InputStream fraw_postres = getResources().openRawResource(R.raw.menu_postres);
			menu_primeros.setGravity(Gravity.CENTER);

			BufferedReader brin = new BufferedReader(
					new InputStreamReader(fraw_primeros));

			while (brin.read() != -1) {
				linea = brin.readLine();
				menu_primeros.append(linea);
				menu_primeros.append("\n");
				}
			fraw_primeros.close();
			
			BufferedReader brin2 = new BufferedReader(
					new InputStreamReader(fraw_segundos));

			while (brin2.read() != -1) {
				linea = brin2.readLine();
				menu_segundos.append(linea);
				menu_segundos.append("\n");
			}
			fraw_segundos.close();
			
			
			BufferedReader brin3 = new BufferedReader(
					new InputStreamReader(fraw_postres));

			while (brin3.read() != -1) {
				linea = brin3.readLine();
				menu_postres.append(linea);
				menu_postres.append("\n");
			}
			fraw_postres.close();
			
		} catch (Exception ex) {
			Log.e("Ficheros", "Error al leer fichero desde recurso raw");
		}
		
		
	}

}
